Imports DAL
Imports MyClasses
Imports System.Collections
Imports System.Configuration
Imports C1.Win

Public Class frmItemMaster
    Public intItemNo As Integer
    Public flgItem As Byte
    Dim SubstituteItem(0) As Integer
    Dim tax(0) As CTax
    Dim dtbSuDItem As DataTable
    Dim dtsSubstituteItem As New DataSet
    Dim blnTaxDetails As Byte
    Dim blnchngType As Boolean
    Dim btLoading As Boolean

#Region "SomeThing Extra"
    'Bool  0 For No/False
    'Bool  1 For Yes/True
#End Region

    Private Sub txtItemName_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtItemName.KeyDown
        Try
            If e.Alt Then Exit Sub
            If e.KeyCode = Keys.Enter Then cmbcompanyname.Focus()
            If e.Shift = True Then
                If e.KeyCode = Keys.OemQuotes Or e.KeyCode = Keys.OemPeriod Then
                    e.SuppressKeyPress = True
                End If
                If BCommon.ValidateText(e.KeyCode, "ALF", False) = False Then
                    e.SuppressKeyPress = True
                End If
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtUsername_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbType_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbType.KeyUp
        Try
            If e.KeyCode = Keys.Enter Then cmbCategory.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbType_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbCategory_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbCategory.KeyUp
        Try
            If e.KeyCode = Keys.Enter Then cmbForm.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbCategory_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbForm_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbForm.KeyUp
        Try
            If e.KeyCode = Keys.Enter Then cmbGrade.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbForm_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbGrade_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbGrade.KeyUp
        Try
            If e.KeyCode = Keys.Enter Then cmbGenericName.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbGrade_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbGenericName_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbGenericName.KeyUp
        Try
            If e.KeyCode = Keys.Enter Then cmbPurPack.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbGenericName_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbPurPack_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbPurPack.KeyUp
        Try
            If e.KeyCode = Keys.Enter Then txtPurQty.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbPurPack_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtPurQty_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPurQty.KeyDown
        Try
            If e.Alt Then Exit Sub
            If e.KeyCode = Keys.Enter Then cmbUOM.Focus()
            If e.Shift Then e.SuppressKeyPress = True : Exit Sub
            If BCommon.ValidateText(e.KeyCode, "NUM", False) = False Then
                e.SuppressKeyPress = True
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtPurQty_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbSchDrug_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbSchDrug.KeyUp
        Try
            If e.KeyCode = Keys.Enter Then cmbSellLoose.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbSchDrug_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbSellLoose_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbSellLoose.KeyUp
        Try
            If e.KeyCode = Keys.Enter Then txtRemarks.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbSellLoose_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtRemarks_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtRemarks.KeyDown
        If e.Alt Then Exit Sub
        If e.KeyCode = Keys.Enter Then
            cmbLocation.Focus()
        Else
            If BCommon.ValidateText(e.KeyCode, "ALFTEXT", False) = False Then
                e.SuppressKeyPress = True
            End If
        End If
    End Sub

    Private Sub txtRemarks_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtRemarks.KeyUp
        Try
            If e.KeyCode = Keys.Enter Then cmbLocation.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtRemarks_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtMinQty_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtMinQty.KeyDown
        Try
            If e.Alt Then Exit Sub
            If e.KeyCode = Keys.Enter Then txtMaxQty.Focus()
            If e.Shift Then e.SuppressKeyPress = True : Exit Sub
            If BCommon.ValidateText(e.KeyCode, "NUM", False) = False Then
                e.SuppressKeyPress = True
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtMinQty_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtMaxQty_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtMaxQty.KeyDown
        Try
            If e.Alt Then Exit Sub
            If e.KeyCode = Keys.Enter Then txtROL.Focus()
            If e.Shift Then e.SuppressKeyPress = True : Exit Sub
            If BCommon.ValidateText(e.KeyCode, "NUM", False) = False Then
                e.SuppressKeyPress = True
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtMaxQty_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtROL_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtROL.KeyDown
        Try
            If e.Alt Then Exit Sub
            If e.KeyCode = Keys.Enter Then txtROQ.Focus()
            If e.Shift Then e.SuppressKeyPress = True : Exit Sub
            If BCommon.ValidateText(e.KeyCode, "NUM", False) = False Then
                e.SuppressKeyPress = True
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtROL_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtROQ_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtROQ.KeyDown
        Try
            If e.Alt Then Exit Sub
            If e.KeyCode = Keys.Enter Then txtMaxDiscount.Focus()
            If e.Shift Then e.SuppressKeyPress = True : Exit Sub
            If BCommon.ValidateText(e.KeyCode, "NUM", False) = False Then
                e.SuppressKeyPress = True
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtROQ_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtMaxDiscount_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtMaxDiscount.KeyDown
        Try
            'Rahul_ITS@20071119
            If e.Alt Then Exit Sub
            If e.KeyCode = Keys.Shift Then e.SuppressKeyPress = True
            If e.KeyCode = Keys.Enter Then txtMargin.Focus()
            If e.KeyCode = Keys.Shift Then e.SuppressKeyPress = True
            e.SuppressKeyPress = Not BCommon.ValidateText(e.KeyCode, "NUM", False)
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtMaxDiscount_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtMaxDiscount_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtMaxDiscount.KeyUp
        'Rahul_ITS@20071119
        Try
            If (BCommon.IsInteger(txtMaxDiscount.Text) = False) Then txtMaxDiscount.Focus() : txtMaxDiscount.Text = ""
            If e.KeyCode = Keys.Enter Then txtMaxDiscount.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtMaxDiscount_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbPreferredV1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbPreferredV1.KeyDown
        If e.Alt Then Exit Sub
        If e.KeyCode = Keys.Enter Then
            If sender.selectedindex = -1 Then sender.text = "" Else cmbPreferredV2.Focus()
        End If
    End Sub

    Private Sub cmbPreferredV2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbPreferredV2.KeyDown
        If e.Alt Then Exit Sub
        If e.KeyCode = Keys.Enter Then
            If sender.selectedindex = -1 Then sender.text = "" Else cmbPreferredV3.Focus()
        End If
    End Sub

    Private Sub cmbPreferredV3_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbPreferredV3.KeyDown
        If e.Alt Then Exit Sub
        If e.KeyCode = Keys.Enter Then
            If sender.selectedindex = -1 Then sender.text = "" Else cmbAction1.Focus()
        End If
    End Sub

    Private Sub cmbAction1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbAction1.KeyDown
        If e.Alt Then Exit Sub
        If e.KeyCode = Keys.Enter Then
            If sender.selectedindex = -1 Then sender.text = "" Else cmbAction2.Focus()
        End If
    End Sub

    Private Sub cmbAction2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbAction2.KeyDown
        If e.Alt Then Exit Sub
        If e.KeyCode = Keys.Enter Then
            If sender.selectedindex = -1 Then sender.text = "" Else cmbAction3.Focus()
        End If
    End Sub

    Private Sub cmbAction3_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbAction3.KeyDown
        If e.Alt Then Exit Sub
        If e.KeyCode = Keys.Enter Then
            If sender.selectedindex = -1 Then sender.text = "" Else FGTaxDetails.Focus()
        End If
    End Sub

    Private Sub txtBarCode_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtBarCode.GotFocus
        Try
            If txtBarCode.Text = txtBarCode.Tag Then
                txtBarCode.Text = ""
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtBarCode_GotFocus")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtBarCode_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtBarCode.KeyUp
        Try
            If e.KeyCode = Keys.Enter Then
                cmbcompanyname.Focus()
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtBarCode_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtBarCode_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtBarCode.LostFocus
        Try
            If Trim(txtBarCode.Text) = "" Then
                txtBarCode.Text = txtBarCode.Tag
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtBarCode_LostFocus")
            Me.Cursor = Cursors.Default
        End Try
    End Sub


    Private Sub txtItemCode_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtItemCode.KeyDown
        If e.Alt Then Exit Sub
        If e.KeyCode = Keys.Enter Then
            txtBarCode.Focus()
        Else
            If BCommon.ValidateText(e.KeyCode, "ALFTEXT", False) = False Then
                e.SuppressKeyPress = True
            End If
        End If
    End Sub

    Private Sub txtItemCode_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtItemCode.KeyUp
        Try
            If e.KeyCode = Keys.Enter Then
                If txtBarCode.Visible = True Then
                    txtBarCode.Focus()
                Else
                    cmbcompanyname.Focus()
                End If
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtItemCode_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbmfctrname_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbmfctrname.KeyUp
        Try
            If e.KeyCode = Keys.Enter Then cmbType.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbmfctrname_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbcompanyname_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbcompanyname.KeyDown
        If e.Alt Then Exit Sub
        If e.KeyCode = Keys.Enter Then
            If sender.selectedindex = -1 Then
                sender.text = ""
            Else
                If chkSameCompany.Checked = False Then
                    cmbmfctrname.Focus()
                Else
                    cmbType.Focus()
                End If
            End If
        End If
    End Sub

    Private Sub txtMargin_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtMargin.KeyDown
        Try
            'Rahul_ITS@20071119
            If e.Alt Then Exit Sub
            If e.KeyCode = Keys.Shift Then e.SuppressKeyPress = True
            If e.KeyCode = Keys.Enter Then txtELStock.Focus()
            If e.KeyCode = Keys.Shift Then e.SuppressKeyPress = True
            e.SuppressKeyPress = Not BCommon.ValidateText(e.KeyCode, "NUM", False)
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtMargin_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    <System.ComponentModel.Description("")> _
    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            Call SaveData()
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnSave_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            Dim form As New frmMasterBrowse
            form.strSearch = "Item"
            'Rahul_ITS@20072612
            '<<START
            form.StartPosition = FormStartPosition.Manual
            form.Height = MDIPharmacy.MdiScaleHeight
            form.Width = MDIPharmacy.MdiScaleWidth
            Dim pt As New Point
            pt.Y = ((MDIPharmacy.MdiScaleHeight - form.Height) / 2) + MDIPharmacy.pnlHeading.Height + MDIPharmacy.MenuStrip.Height
            pt.X = (MDIPharmacy.MdiScaleWidth - form.Width) / 2
            form.Location = pt
            form.ShowInTaskbar = False
            '>>END
            form.ShowDialog()
            intItemNo = form.strRecordNo

            If intItemNo <> 0 Then
                Call ClearData()
                Call ViewData()
                btnSave.Text = "&Update"
                cmbPurPack.Enabled = False
                txtPurQty.Enabled = False
                cmbUOM.Enabled = False
                cmbSellLoose.Enabled = False
                txtItemCode.Enabled = False
                If ConfigurationManager.AppSettings("FormMode") = "R" Then
                    btnDelete.Enabled = False
                Else
                    btnDelete.Enabled = True
                End If
            End If
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnSearch_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            Display_Data()
            btnSave.Text = "&Save"
            cmbPurPack.Enabled = True
            txtPurQty.Enabled = True
            cmbUOM.Enabled = True
            cmbSellLoose.Enabled = True
            btnDelete.Enabled = False
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnCancel_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Function ValidateData() As Boolean
        Dim intvar As String
        Dim intpos As String
        Dim intlen As String

        Try
            If Trim(txtItemName.Text) = "" Then
                BCommon.ShowMsgError(10021)
                txtItemName.Focus()
                Return False
            End If

            If cmbcompanyname.SelectedValue = Nothing Then
                BCommon.ShowMsgError(10210)
                cmbcompanyname.Focus()
                Return False
            End If

            If chkSameCompany.Checked = False Then
                If Trim(cmbmfctrname.Text) = "" Then
                    BCommon.ShowMsgError(10022)
                    cmbmfctrname.Focus()
                    Return False
                End If
            End If

            If Trim(cmbType.Text) = "" Then
                BCommon.ShowMsgError(10023)
                cmbType.Focus()
                Return False
            End If

            If Trim(cmbCategory.Text) = "" Then
                BCommon.ShowMsgError(10024)
                cmbCategory.Focus()
                Return False
            End If

            If Trim(cmbForm.Text) = "" Then
                BCommon.ShowMsgError(10025)
                cmbForm.Focus()
                Return False
            End If

            If Trim(cmbPurPack.Text) = "" Then
                BCommon.ShowMsgError(10026)
                cmbPurPack.Focus()
                Return False
            End If

            If Trim(txtPurQty.Text) = "" Or Trim(txtPurQty.Text) = "0" Then
                BCommon.ShowMsgError(10027)
                txtPurQty.Focus()
                Return False
            End If

            If Trim(cmbUOM.Text) = "" Then
                BCommon.ShowMsgError(10028)
                cmbUOM.Focus()
                Return False
            End If

            If Trim(cmbLocation.Text) = "" Then
                BCommon.ShowMsgError(10030)
                cmbLocation.Focus()
                Return False
            End If

            If CDbl(txtMinQty.Text) > CDbl(txtROL.Text) Then
                BCommon.ShowMsgError(10325)
                txtMinQty.Focus()
                Return False
            End If

            If CDbl(IIf(Trim(txtMaxQty.Text) = "", 0, Trim(txtMaxQty.Text))) < CDbl(IIf(Trim(txtROL.Text) = "", 0, Trim(txtROL.Text))) Then
                BCommon.ShowMsgError(10365)
                txtMaxQty.Focus()
                Return False
            End If

            If CDbl(IIf(Trim(txtROL.Text) = "", 0, Trim(txtROL.Text))) > CDbl(IIf(Trim(txtMaxQty.Text) = "", 0, Trim(txtMaxQty.Text))) Then
                BCommon.ShowMsgError(10360)
                txtROL.Focus()
                Return False
            End If

            intvar = txtMargin.Text
            intpos = (intvar.IndexOf("."))
            intlen = (Len(intvar))
            If intpos > 2 Or (intpos < 0 And intlen > 2) Then
                BCommon.ShowMsgError(10245)
                txtMargin.Focus()
                Return False
            End If
            'Rahul_ITS@20071113
            'Start <<
            If (cmbPreferredV1.SelectedIndex = 0 Or cmbPreferredV2.SelectedIndex = 0 Or cmbPreferredV3.SelectedIndex = 0) Or _
            (cmbPreferredV1.SelectedIndex = 0 And cmbPreferredV2.SelectedIndex = 0) Or _
            (cmbPreferredV1.SelectedIndex = 0 And cmbPreferredV3.SelectedIndex = 0) Or _
            (cmbPreferredV2.SelectedIndex = 0 And cmbPreferredV3.SelectedIndex = 0) Then
            Else
                If (cmbPreferredV1.SelectedIndex > 0 Or cmbPreferredV2.SelectedIndex > 0 Or cmbPreferredV3.SelectedIndex > 0) Or _
            (cmbPreferredV1.SelectedIndex > 0 And cmbPreferredV2.SelectedIndex > 0) Or _
            (cmbPreferredV1.SelectedIndex > 0 And cmbPreferredV3.SelectedIndex > 0) Or _
            (cmbPreferredV2.SelectedIndex > 0 And cmbPreferredV3.SelectedIndex > 0) Then
                    If ((cmbPreferredV1.SelectedValue = cmbPreferredV2.SelectedValue) _
                    Or (cmbPreferredV1.SelectedValue = cmbPreferredV3.SelectedValue) _
                    Or (cmbPreferredV2.SelectedValue = cmbPreferredV1.SelectedValue) _
                    Or (cmbPreferredV2.SelectedValue = cmbPreferredV3.SelectedValue) _
                    Or (cmbPreferredV3.SelectedValue = cmbPreferredV1.SelectedValue) _
                    Or (cmbPreferredV3.SelectedValue = cmbPreferredV2.SelectedValue)) Then
                        BCommon.ShowMsgError(10246)
                        Return False
                    End If
                End If
            End If
            '>> END
            Return True
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "ValidateData")
            Me.Cursor = Cursors.Default
        End Try
    End Function

    Private Sub SaveData()
        Try
            If ValidateData() = False Then Exit Sub
            If ValidateItem() = False Then Exit Sub

            Dim objItem As New CItem
            objItem = SetData()
            If btnSave.Text = "&Save" Then
                intItemNo = DItem.Save(objItem, "S", SetSubstitute(), SetTax())
                If intItemNo > 0 Then BCommon.ShowMsgError(3) Else BCommon.ShowMsgError(4)
            Else
                If DItem.Save(objItem, "U", SetSubstitute(), SetTax()) > 0 Then BCommon.ShowMsgError(5) Else BCommon.ShowMsgError(4)
            End If
            Call ClearData()
            btnSave.Text = "&Save"
            cmbPurPack.Enabled = True
            txtPurQty.Enabled = True
            cmbUOM.Enabled = True
            cmbSellLoose.Enabled = True
            btnDelete.Enabled = False
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "SaveData")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub ClearData()
        Try
            btLoading = True
            txtItemCode.Text = BCommon.GetSequentialID("ITEM")
            txtItemName.Text = ""
            cmbmfctrname.SelectedIndex = -1
            cmbcompanyname.SelectedIndex = -1
            txtBarCode.Text = txtBarCode.Tag
            cmbType.SelectedValue = "MEDICAL"
            cmbCategory.SelectedValue = 5
            cmbForm.SelectedIndex = -1
            cmbGrade.SelectedIndex = -1
            cmbGenericName.SelectedIndex = -1
            cmbPurPack.SelectedIndex = -1
            txtPurQty.Text = 0
            cmbUOM.SelectedValue = "MG"
            cmbSchDrug.SelectedIndex = -1
            cmbSellLoose.SelectedIndex = -1
            txtRemarks.Text = ""
            cmbLocation.SelectedIndex = -1
            txtMinQty.Text = 0
            txtMaxQty.Text = 0
            txtROL.Text = 0
            txtROQ.Text = 0
            txtMaxDiscount.Text = "0.00"
            txtMargin.Text = "0.00" 'Rahul_ITS@20071112 : Add New field 
            txtELStock.Text = 0 'Rahul_ITS@20071113 : Add New field
            cmbPreferredV1.SelectedIndex = -1
            cmbPreferredV2.SelectedIndex = -1
            cmbPreferredV3.SelectedIndex = -1
            cmbAction1.SelectedIndex = -1
            cmbAction2.SelectedIndex = -1
            cmbAction3.SelectedIndex = -1
            FGTaxDetails.Clear(C1FlexGrid.ClearFlags.UserData)
            FGTaxDetails.Rows.Count = 1
            fgItemList.Clear(C1FlexGrid.ClearFlags.UserData)
            fgItemList.Rows.Count = 1
            Call clearTag()
            Call setTag()
            btnDelete.Enabled = False
            btLoading = False
            If ConfigurationManager.AppSettings("FormMode") = "R" Then
                cmbmfctrname.Enabled = False
                cmbcompanyname.Enabled = False
            Else
                cmbmfctrname.Enabled = True
                cmbcompanyname.Enabled = True
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "ClearData")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub Display_Data()
        Dim dtbVendor As DataTable
        Dim dtbVendor2 As DataTable
        Dim dtbvendor3 As DataTable
        Dim dtbLocation As DataTable
        Dim dtbmfctr As DataTable
        Dim dtbcompany As DataTable
        Try
            Call ClearData()
            btLoading = True
            If BCommon.GetConfigValues("BarCode") = "N" Then txtBarCode.Visible = False

            chkSameCompany.Checked = True
            BCommon.SetComboValues(cmbGrade, "ITEMGRADE", True)
            BCommon.SetComboValues(cmbType, "ITEM_TYPE")
            BCommon.SetComboValues(cmbCategory, "ITEM_CATEGORY")
            BCommon.SetComboValues(cmbForm, "ITEMFORM")
            BCommon.SetComboValues(cmbGenericName, "GENERICNAME", True)

            BuildAutoCompleteCombo(cmbGenericName)

            BCommon.SetComboValues(cmbPurPack, "PURPACK")
            BCommon.SetComboValues(cmbUOM, "SALEUNIT")
            BCommon.SetComboValues(cmbAction1, "DRUGACTION", True)
            BCommon.SetComboValues(cmbAction2, "DRUGACTION", True)
            BCommon.SetComboValues(cmbAction3, "DRUGACTION", True)
            BCommon.SetComboValues(cmbSchDrug, "SCHEDULETYPE", True)
            BCommon.SetComboValues(cmbSellLoose, "Bool")

            dtbVendor = BVendor.GetVendor()
            dtbVendor2 = dtbVendor.Copy
            dtbvendor3 = dtbVendor.Copy

            BCommon.SetComboValues(cmbPreferredV1, dtbVendor, "VendorID", "VendorName")
            BCommon.SetComboValues(cmbPreferredV2, dtbVendor2, "VendorID", "VendorName")
            BCommon.SetComboValues(cmbPreferredV3, dtbvendor3, "VendorID", "VendorName")

            'Set the Location Data in the ComboBox=Modified by:-VINIT:-(20080312)
            dtbLocation = BCommon.GetLocation()
            BCommon.SetComboValues(cmbLocation, dtbLocation, "LocationID", "LocationCode")

            'Set the Manufacturer Data in the ComboBox and Grid=Modified by:-VINIT:-(20080312)
            dtbmfctr = BManufacturer.GetManufacturer()
            cmbmfctrname.DataSource = dtbmfctr
            cmbmfctrname.ValueMember = "mfctrID"
            cmbmfctrname.DisplayMember = "mfctrname"
            cmbmfctrname.Splits(0).DisplayColumns(1).Width = cmbmfctrname.Width * 35 / 100
            cmbmfctrname.Splits(0).DisplayColumns(2).Width = cmbmfctrname.Width * 59 / 100
            cmbmfctrname.Columns(1).Caption = "CODE"
            cmbmfctrname.Columns(2).Caption = "COMPANY NAME"
            cmbmfctrname.Splits(0).DisplayColumns(0).Visible = False

            'Set the Manufacturer Data in the ComboBox and Grid=Modified by:-VINIT:-(20080312)
            dtbcompany = BManufacturer.GetManufacturer()
            cmbcompanyname.DataSource = dtbcompany
            cmbcompanyname.ValueMember = "mfctrID"
            cmbcompanyname.DisplayMember = "mfctrname"
            cmbcompanyname.Splits(0).DisplayColumns(1).Width = cmbcompanyname.Width * 30 / 100
            cmbcompanyname.Splits(0).DisplayColumns(2).Width = cmbcompanyname.Width * 59 / 100
            cmbcompanyname.Columns(1).Caption = "CODE"
            cmbcompanyname.Columns(2).Caption = "COMPANY NAME"
            cmbcompanyname.Splits(0).DisplayColumns(0).Visible = False

            'Set the Items Data in the ComboBox and Grid=Modified by:-VINIT:-(20080312)
            'dtbSuDItem = DItem.GetItems()
            'ccmDItemList.DataSource = dtbSuDItem
            'ccmDItemList.Splits(0).DisplayColumns(1).Width = ccmDItemList.Width * 130 / 100
            'ccmDItemList.Splits(0).DisplayColumns(2).Width = ccmDItemList.Width * 65 / 100
            'ccmDItemList.Columns(1).Caption = "Item Name"
            'ccmDItemList.Columns(2).Caption = "Code"
            'ccmDItemList.Splits(0).DisplayColumns(0).Visible = False
            'ccmDItemList.DisplayMember = "ItemName"

            'Set the Items Data in the ComboBox and Grid=Modified by:-VINIT:-(20080312)
            Dim dtTax As DataTable = BCommon.GetTaxes()
            If dtTax.Rows.Count > 6 Then
                FGTaxDetails.Rows.Count = dtTax.Rows.Count + 1
            ElseIf dtTax.Rows.Count = 6 Then
                FGTaxDetails.Rows.Count = 7
            Else
                FGTaxDetails.Rows.Count = 6
            End If
            cmbTaxDetails.DataSource = dtTax
            cmbTaxDetails.DisplayMember = "TaxName"
            cmbTaxDetails.ValueMember = "TaxID"

            blnTaxDetails = 1

            blnchngType = True

            cmbType.SelectedValue = "MEDICAL"
            cmbCategory.SelectedValue = 0
            cmbGrade.SelectedValue = 0
            cmbPurPack.SelectedValue = ""
            cmbForm.SelectedValue = ""
            cmbUOM.SelectedValue = "MG"
            cmbSchDrug.SelectedValue = ""
            cmbTaxDetails.Visible = False
            cmbSellLoose.Text = BCommon.SetDefault("SELL_LOOSE")
            If flgItem = 1 Then btnSearch.Enabled = False Else btnSearch.Enabled = True
            txtItemName.Focus()

            BCommon.SetTextReadOnly(txtItemCode) 'Divya 31/01/2008 : Added for ReadOnly fields
            btLoading = False
            Call clearTag()
            Call setTag()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "Display_Data")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub BuildAutoCompleteCombo(ByRef cmbTemp As ComboBox)
        Dim intCount As Integer
        Dim strSource As New AutoCompleteStringCollection
        Try
            For intCount = 0 To cmbTemp.DataSource.Rows.Count - 1
                strSource.Add(cmbTemp.DataSource.Rows(intCount).Item(cmbTemp.DisplayMember))
            Next
            cmbTemp.AutoCompleteCustomSource = strSource
            cmbTemp.AutoCompleteSource = AutoCompleteSource.CustomSource
            cmbTemp.AutoCompleteMode = AutoCompleteMode.Append
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "BuildAutoCompleteCombo")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Function SetData() As CItem
        Dim objItem As New CItem
        Try
            With objItem
                .ItemID = intItemNo
                .SeqItemID = Trim(txtItemCode.Text)
                .ItemName = Trim(txtItemName.Text) & " " & cmbPurPack.Text & "-" & txtPurQty.Text & cmbUOM.Text
                .ShortName = Trim(txtItemName.Text)
                .ItemType = Trim(cmbType.SelectedValue)
                .ItemCategoryID = cmbCategory.SelectedValue
                .CompanyId = Trim(cmbcompanyname.SelectedValue)
                .ManufacturedID = IIf(chkSameCompany.Checked, Trim(cmbcompanyname.SelectedValue), Trim(cmbmfctrname.SelectedValue))
                .BarCode = Trim(txtBarCode.Text)
                .ItemForm = Trim(cmbForm.SelectedValue)
                .ItemGrade = Trim(cmbGrade.SelectedValue)
                .GenericName = Trim(cmbGenericName.SelectedValue)
                .PurPackType = Trim(cmbPurPack.SelectedValue)
                .ItemsPerPack = Trim(txtPurQty.Text)
                .PurchaseUnit = Trim(cmbUOM.SelectedValue)
                .ItemUnit = Trim(cmbUOM.SelectedValue)
                .SellUnit = IIf(cmbSellLoose.SelectedValue = 0, cmbUOM.SelectedValue, cmbPurPack.SelectedValue)
                .Scheduletype = cmbSchDrug.SelectedValue
                .SellInLoose = cmbSellLoose.SelectedValue
                .Remark = Trim(txtRemarks.Text)
                .LocationID = Trim(cmbLocation.SelectedValue)
                .MinQuantity = Trim(txtMinQty.Text)
                .MaxQuantity = Trim(txtMaxQty.Text)
                .BarCode = IIf(txtBarCode.Text <> txtBarCode.Tag, Trim(txtBarCode.Text), "")
                .MinReOrderLevel = Trim(txtROL.Text)
                .MaxReOrderQty = Trim(txtROQ.Text)
                .MaxDiscount = Trim(txtMaxDiscount.Text)

                ' Rahul_ITS@20071112 add following line 
                'Start <<
                .Margin = Trim(txtMargin.Text)

                If Trim(txtELStock.Text = "") Then
                    .Emergency = 0
                Else
                    .Emergency = Trim(txtELStock.Text)
                End If
                ' >> End
                .VendorID1 = cmbPreferredV1.SelectedValue
                .VendorID2 = cmbPreferredV2.SelectedValue
                .VendorID3 = cmbPreferredV3.SelectedValue
                .Action1 = cmbAction1.SelectedValue
                .Action2 = cmbAction2.SelectedValue
                .Action3 = cmbAction3.SelectedValue
            End With
            Return objItem
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "Setdata")
            Me.Cursor = Cursors.Default
            Return Nothing
        End Try
    End Function

    Public Function SetSubstitute() As Integer()
        Dim tempSubstitute(0) As Integer
        If fgItemList.Item(1, 1) = "" Then
            tempSubstitute(0) = New Integer
            tempSubstitute(0) = 0
            Return tempSubstitute
        End If

        Dim intcount As Integer
        ReDim tempSubstitute(fgItemList.Rows.Count - 3)
        Try
            For intcount = 0 To fgItemList.Rows.Count - 3
                If (Not IsNothing(fgItemList.Item(intcount + 1, 1))) Then
                    tempSubstitute(intcount) = New Integer
                    tempSubstitute(intcount) = fgItemList.Item(intcount + 1, 2)
                End If
            Next
            Return tempSubstitute
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "SetSubStitute")
            Me.Cursor = Cursors.Default
            Return Nothing
        End Try
    End Function

    Public Function SetTax() As CTax()

        ReDim tax(FGTaxDetails.Rows.Count - 3)

        Try
            Dim intcount As Integer
            For intcount = 0 To FGTaxDetails.Rows.Count - 3
                'If (Not IsNothing(FGTaxDetails.Item(intcount + 1, 1))) Then
                tax(intcount) = New CTax
                tax(intcount).TaxID = FGTaxDetails.Item(intcount + 1, 0)
                tax(intcount).TaxName = IIf(FGTaxDetails.Item(intcount + 1, 1) = Nothing, "", FGTaxDetails.Item(intcount + 1, 1))
                tax(intcount).TaxAmount = FGTaxDetails.Item(intcount + 1, 3)
                'Else
                'tax(intcount).TaxID = 0
                'End If
            Next
            Return tax
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "SetTax")
            Me.Cursor = Cursors.Default
            Return Nothing
        End Try
    End Function

    Private Sub ViewData()

        Dim dtsItem As New DataSet
        Dim dtsTax As New DataSet
        Try
            dtsItem = DItem.GetItem(intItemNo)

            If dtsItem.Tables(0).Rows.Count = 0 Then : BCommon.ShowMsgError(10082)
                Exit Sub
            End If
            dtsTax = DItem.GetTax(intItemNo)
            dtsSubstituteItem = DItem.GetSubstituteItem(intItemNo)
            With dtsItem.Tables(0).Rows(0)
                txtItemCode.Text = .Item(1)
                txtItemName.Text = .Item(2)
                cmbType.SelectedValue = .Item(4)
                cmbCategory.SelectedValue = .Item(5)
                cmbForm.SelectedValue = .Item(6)
                cmbGrade.SelectedValue = .Item(7)
                cmbmfctrname.SelectedValue = .Item(8)
                cmbcompanyname.SelectedValue = .Item(9)
                cmbGenericName.SelectedValue = .Item(10)
                cmbUOM.SelectedValue = .Item(11)
                cmbPurPack.SelectedValue = .Item(12)
                txtPurQty.Text = .Item(13)
                cmbLocation.SelectedValue = .Item(15)
                cmbSellLoose.SelectedValue = Int(.Item(16))

                If txtBarCode.Visible = True And .Item(21) <> "" Then
                    txtBarCode.Text = .Item(21)
                Else
                    txtBarCode.Text = txtBarCode.Tag
                End If

                txtMaxDiscount.Text = .Item(22)
                txtMargin.Text = .Item(23)
                txtMinQty.Text = .Item(24)
                txtMaxQty.Text = .Item(25)
                txtROL.Text = .Item(26)
                txtROQ.Text = .Item(27)
                cmbAction1.SelectedValue = .Item(28)
                cmbAction2.SelectedValue = .Item(29)
                cmbAction3.SelectedValue = .Item(30)
                cmbPreferredV1.SelectedValue = .Item(31)
                cmbPreferredV2.SelectedValue = .Item(32)
                cmbPreferredV3.SelectedValue = .Item(33)
                cmbSchDrug.SelectedValue = (.Item(34))
                txtRemarks.Text = .Item(35)
                txtELStock.Text = .Item(36)

            End With

            Dim intcount As Integer

            If dtsSubstituteItem.Tables(0).Rows.Count > 0 Then fgItemList.Rows.Count = dtsSubstituteItem.Tables(0).Rows.Count + 2
            ReDim SubstituteItem(dtsSubstituteItem.Tables(0).Rows.Count - 1)
            For intcount = 0 To dtsSubstituteItem.Tables(0).Rows.Count - 1
                fgItemList.Item(intcount + 1, 1) = dtsSubstituteItem.Tables(0).Rows(intcount).Item(0)
                fgItemList.Item(intcount + 1, 2) = dtsSubstituteItem.Tables(0).Rows(intcount).Item(1)
                SubstituteItem(intcount) = dtsSubstituteItem.Tables(0).Rows(intcount).Item(1)
            Next
            fgItemList.Cols(2).Visible = False

            If dtsTax.Tables(0).Rows.Count > 0 Then

                FGTaxDetails.Rows.Count = dtsTax.Tables(0).Rows.Count + 2
                With dtsTax.Tables(0)
                    For intcount = 0 To dtsTax.Tables(0).Rows.Count - 1
                        FGTaxDetails.Item(intcount + 1, 1) = .Rows(intcount).Item(0)
                        FGTaxDetails.Item(intcount + 1, 2) = .Rows(intcount).Item(1)
                        FGTaxDetails.Item(intcount + 1, 3) = .Rows(intcount).Item(2)
                        FGTaxDetails.Item(intcount + 1, 4) = .Rows(intcount).Item(5)
                        FGTaxDetails.Item(intcount + 1, 0) = .Rows(intcount).Item(3)
                    Next
                End With
            End If
            FGTaxDetails.Cols(2).Visible = False
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "ViewData")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub clearTag()
        Try
            txtItemCode.Tag = ""
            txtItemName.Tag = ""
            cmbType.Tag = ""
            cmbCategory.Tag = ""
            cmbForm.Tag = ""
            cmbGrade.Tag = ""
            cmbmfctrname.Tag = ""
            cmbcompanyname.Tag = ""
            cmbGenericName.Tag = ""
            cmbUOM.Tag = ""
            cmbPurPack.Tag = ""
            txtPurQty.Tag = ""
            cmbLocation.Tag = ""
            cmbSellLoose.Tag = ""
            txtMaxDiscount.Tag = ""
            txtMargin.Tag = ""
            txtELStock.Tag = ""
            txtMinQty.Tag = ""
            txtMaxQty.Tag = ""
            txtROL.Tag = ""
            txtROQ.Tag = ""
            cmbAction1.Tag = ""
            cmbAction2.Tag = ""
            cmbAction3.Tag = ""
            cmbPreferredV1.Tag = ""
            cmbPreferredV2.Tag = ""
            cmbPreferredV3.Tag = ""
            cmbSchDrug.Tag = ""
            txtRemarks.Tag = ""
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "clearTag")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub setTag()
        Try
            txtItemCode.Tag = txtItemCode.Text
            txtItemName.Tag = txtItemName.Text
            cmbType.Tag = cmbType.SelectedValue
            cmbCategory.Tag = cmbCategory.SelectedValue
            cmbForm.Tag = cmbForm.SelectedValue
            cmbGrade.Tag = cmbGrade.SelectedValue
            cmbmfctrname.Tag = cmbmfctrname.SelectedValue
            cmbcompanyname.Tag = cmbcompanyname.SelectedValue
            cmbGenericName.Tag = cmbGenericName.SelectedValue
            cmbUOM.Tag = cmbUOM.SelectedValue
            cmbPurPack.Tag = cmbPurPack.SelectedValue
            txtPurQty.Tag = txtPurQty.Text
            cmbLocation.Tag = cmbLocation.SelectedValue
            cmbSellLoose.Tag = cmbSellLoose.SelectedValue
            txtMaxDiscount.Tag = txtMaxDiscount.Text
            txtMargin.Tag = txtMargin.Text
            txtELStock.Tag = txtELStock.Text
            txtMinQty.Tag = txtMinQty.Text
            txtMaxQty.Tag = txtMaxQty.Text
            txtROL.Tag = txtROL.Text
            txtROQ.Tag = txtROQ.Text
            cmbAction1.Tag = cmbAction1.SelectedValue
            cmbAction2.Tag = cmbAction2.SelectedValue
            cmbAction3.Tag = cmbAction3.SelectedValue
            cmbPreferredV1.Tag = cmbPreferredV1.SelectedValue
            cmbPreferredV2.Tag = cmbPreferredV2.SelectedValue
            cmbPreferredV3.Tag = cmbPreferredV3.SelectedValue
            cmbSchDrug.Tag = cmbSchDrug.SelectedValue
            txtRemarks.Tag = txtRemarks.Text
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "setTag")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Function isUpdated() As Boolean
        Try
            If checkTag() Then
                Return True
            Else
                Return False
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "isUpdated")
            Me.Cursor = Cursors.Default
        End Try
    End Function

    Private Function checkTag() As Boolean
        Try
            If Trim(txtItemCode.Text) <> Trim(txtItemCode.Tag) OrElse Trim(txtItemName.Text) <> Trim(txtItemName.Tag) _
               OrElse cmbType.SelectedValue <> cmbType.Tag OrElse cmbCategory.SelectedValue <> cmbCategory.Tag _
               OrElse cmbForm.SelectedValue <> cmbForm.Tag OrElse cmbGrade.SelectedValue <> cmbGrade.Tag _
               OrElse cmbmfctrname.SelectedValue <> cmbmfctrname.Tag OrElse cmbcompanyname.SelectedValue <> cmbcompanyname.Tag _
               OrElse cmbGenericName.SelectedValue <> cmbGenericName.Tag OrElse cmbUOM.SelectedValue <> cmbUOM.Tag _
               OrElse cmbPurPack.SelectedValue <> cmbPurPack.Tag OrElse Trim(txtPurQty.Text) <> Trim(txtPurQty.Tag) _
               OrElse cmbLocation.SelectedValue <> cmbLocation.Tag OrElse cmbSellLoose.SelectedValue <> cmbSellLoose.Tag _
               OrElse Trim(txtMaxDiscount.Text) <> Trim(txtMaxDiscount.Tag) OrElse Trim(txtMargin.Text) <> Trim(txtMargin.Tag) _
               OrElse Trim(txtMinQty.Text) <> Trim(txtMinQty.Tag) OrElse Trim(txtELStock.Text) <> Trim(txtELStock.Tag) _
               OrElse Trim(txtMaxQty.Text) <> Trim(txtMaxQty.Tag) OrElse Trim(txtROL.Text) <> Trim(txtROL.Tag) _
               OrElse Trim(txtROQ.Text) <> Trim(txtROQ.Tag) OrElse cmbAction1.SelectedValue <> cmbAction1.Tag _
               OrElse cmbAction2.SelectedValue <> cmbAction2.Tag OrElse cmbAction3.SelectedValue <> cmbAction3.Tag _
               OrElse cmbPreferredV1.SelectedValue <> cmbPreferredV1.Tag OrElse cmbPreferredV2.SelectedValue <> cmbPreferredV2.Tag _
               OrElse cmbPreferredV3.SelectedValue <> cmbPreferredV3.Tag OrElse cmbSchDrug.SelectedValue <> cmbSchDrug.Tag _
               OrElse Trim(txtRemarks.Text) <> Trim(txtRemarks.Tag) Then
                Return True
            Else : Return False
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "checkTag")
            Me.Cursor = Cursors.Default
        End Try
    End Function

    Private Sub frmItemMaster_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Try
            If Not (ConfigurationManager.AppSettings("FormMode") = "R") Then
                Me.Cursor = Cursors.WaitCursor
                If isUpdated() = True Then
                    Select Case BCommon.ShowMsgError(10081, "YNC")
                        Case Windows.Forms.DialogResult.Yes
                            If ValidateData() Then
                                Call SaveData()
                            Else
                                e.Cancel = True
                            End If
                        Case Windows.Forms.DialogResult.Cancel
                            e.Cancel = True
                        Case Windows.Forms.DialogResult.No
                    End Select
                End If
                Me.Cursor = Cursors.Default
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnClose_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub frmItemMaster_HelpButtonClicked(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.HelpButtonClicked
        'Rauhl_ITS@20073012 : Add following code display help
        Help.ShowHelp(Me, "Pharma.chm", HelpNavigator.KeywordIndex, "Item Master")
        e.Cancel = True
    End Sub

    Private Sub frmItemMaster_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
        If e.KeyCode = Keys.F1 Then
            'Rauhl_ITS@20073012 : Add following code display help
            e.SuppressKeyPress = True
            Help.ShowHelp(Me, "Pharma.chm", HelpNavigator.KeywordIndex, "Item Master")
        End If
    End Sub

    ''Divya@01/07/2008 
    Private Sub GetTaxApplyTo(ByVal TaxName As String)
        Dim dtAppTo As New DataTable
        Dim count As Integer
        Try
            With FGTaxDetails
                .Cols(4).AllowEditing = False
                .Cols(4).Visible = True
                For count = 0 To .Rows.Count
                    If .Item(count + 1, 1) = "" Or .Item(count + 1, 1) = Nothing Then Exit Sub
                    dtAppTo = BTax.GetApplyTo(.Item(count + 1, 1))
                    If dtAppTo.Rows.Count > 0 Then
                        .Item(count + 1, 3) = dtAppTo.Rows(0).Item("Amount")
                        .Item(count + 1, 4) = dtAppTo.Rows(0).Item("ApplyTo")
                    End If
                Next
            End With
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "GetTaxApplyTo")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub frmItemMaster_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            Cursor = Cursors.WaitCursor
            'Dim dt10 As DateTime = Now()
            Call BCommon.SetFormStandards(Me)
            Call Display_Data()
            'MessageBox.Show((Now() - dt10).ToString())
            Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "frmItemMaster_Load")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    'Rahul_ITS@20071122 : Add new function to validate Item Name
    Private Function ValidateItem() As Boolean
        Dim dtbval As DataTable = New DataTable
        Dim ValString As String = ""
        Dim intvar As Integer
        Dim chkStatus As Boolean = True
        Try
            ValString = Trim(txtItemName.Text) & " " & cmbPurPack.Text & "-" & txtPurQty.Text & cmbUOM.Text

            If btnSave.Text <> "&Save" Then
                dtbval = DItem.GetItemByID(intItemNo)

                If dtbval.Rows.Count > 0 Then
                    For intvar = 0 To dtbval.Rows.Count - 1
                        If ValString = dtbval.Rows(intvar).Item("ItemName").ToString() Then
                            BCommon.ShowMsgError(10259)
                            txtItemName.Focus()
                            chkStatus = False
                            Return chkStatus
                        End If
                    Next
                End If
            Else
                dtbval = DItem.GetItemName()

                If dtbval.Rows.Count > 0 Then
                    For intvar = 0 To dtbval.Rows.Count - 1
                        If ValString = dtbval.Rows(intvar).Item("ItemName").ToString() Then
                            BCommon.ShowMsgError(10259)
                            txtItemName.Focus()
                            chkStatus = False
                            Return chkStatus
                        End If
                    Next
                End If
            End If

        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "ValidateItem")
            Me.Cursor = Cursors.Default
            Return False
        End Try
        Return chkStatus
    End Function

    Private Sub cmbTaxDetails_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbTaxDetails.KeyDown
        If e.Alt Then Exit Sub
        If e.KeyCode = Keys.Enter Then
            If sender.selectedindex = -1 Then sender.text = ""
        End If
    End Sub

    Private Sub cmbtaxdetails_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbTaxDetails.SelectedValueChanged
        Try
            If blnTaxDetails = 0 Then Exit Sub
            Dim intcount As Integer = 0
            With FGTaxDetails
                If Not IsNothing(cmbTaxDetails.SelectedValue) Then
                    .Item(.RowSel, 0) = cmbTaxDetails.SelectedValue
                End If

                For intcount = 1 To FGTaxDetails.Rows.Count - 2
                    FGTaxDetails.Rows(.RowSel).Item(0) = cmbTaxDetails.SelectedValue
                Next
            End With
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbtaxdetails_SelectedValueChanged")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbType_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbType.SelectedIndexChanged
        Try
            If blnchngType = False Then
                Exit Sub
            End If

            If cmbType.SelectedValue = "FMCG" Then
                cmbCategory.SelectedValue = 0
            Else
                cmbCategory.SelectedValue = 5
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbType_SelectedIndexChanged")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtMaxDiscount_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMaxDiscount.LostFocus
        Try
            txtMaxDiscount.Text = Format(IIf(Trim(txtMaxDiscount.Text) <> "", CDbl(txtMaxDiscount.Text), 0), "##,##0.00")
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtMaxDiscount_LostFocus")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    'Code Start same tax is not going to be selected               Vrushali...24/10/2007
    Private Sub FGTaxDetails_AfterEdit(ByVal sender As Object, ByVal e As C1.Win.C1FlexGrid.RowColEventArgs) Handles FGTaxDetails.AfterEdit
        Dim intCount As Integer
        Dim strTaxName As String = ""
        Try
            With FGTaxDetails
                If .Col = 1 Then
                    If Not IsNothing(Trim(.Item(.Row, .Col))) Then
                        If cmbTaxDetails.SelectedValue > 0 Then
                            strTaxName = .Item(.Row, 1)
                        End If
                        If .Row > 0 Then
                            For intCount = 1 To .Rows.Count - 1
                                If .Row <> intCount Then
                                    If strTaxName <> Nothing Then
                                        If .Item(intCount, 1) = strTaxName Then
                                            BCommon.ShowMsgError(10216)
                                            '.Rows.Remove(.Row)
                                            .Rows(.Row).Clear(C1.Win.C1FlexGrid.ClearFlags.Content)
                                            .Col = 1
                                            cmbTaxDetails.Focus()
                                            Exit Sub
                                        End If
                                    Else
                                        .Rows(.Row).Clear(C1.Win.C1FlexGrid.ClearFlags.Content)
                                    End If
                                End If
                            Next
                        End If
                    End If
                    Call GetTaxApplyTo(cmbTaxDetails.Text)
                End If
            End With
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "FGTaxDetails_AfterEdit")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub fgItemList_AfterAddRow(ByVal sender As Object, ByVal e As C1.Win.C1FlexGrid.RowColEventArgs) Handles fgItemList.AfterAddRow
        Dim intcount As Integer = 0
        For intcount = 1 To fgItemList.Rows.Count - 2
            fgItemList.Rows(intcount).Item(0) = intcount
        Next
    End Sub

    Private Sub fgItemList_AfterEdit(ByVal sender As Object, ByVal e As C1.Win.C1FlexGrid.RowColEventArgs) Handles fgItemList.AfterEdit
        Dim intCount As Integer, intItemID As Integer
        Try
            With fgItemList
                If .RowSel >= .Rows.Count Or .RowSel < 0 Then Exit Sub
                If .Item(.RowSel, .ColSel) <> "" Then
                    .Item(.RowSel, 2) = dtbSuDItem.Rows(ccmDItemList.SelectedIndex).Item(0)
                End If

                If .Col = 1 Then
                    If Not IsNothing(Trim(.Item(.Row, .Col))) Then
                        If .Item(.Row, 2) > 0 Then
                            intItemID = .Item(.Row, 2)
                        End If
                        If .Row > 0 Then
                            For intCount = 1 To .Rows.Count - 1
                                If .Row <> intCount Then
                                    If intItemID <> Nothing Then
                                        If .Item(intCount, 2) = intItemID Then
                                            BCommon.ShowMsgError(10217)
                                            .Rows(.Row).Clear(C1.Win.C1FlexGrid.ClearFlags.Content)
                                            .Col = 1
                                            ccmDItemList.Focus()
                                            '.Rows.Remove(.Row)
                                            Exit Sub
                                        End If
                                    Else
                                        .Rows(.Row).Clear(C1.Win.C1FlexGrid.ClearFlags.Content)
                                    End If
                                End If
                            Next
                        End If
                    End If
                End If
            End With
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "fgItemList_AfterEdit")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub FGTaxDetails_ValidateEdit(ByVal sender As Object, ByVal e As C1.Win.C1FlexGrid.ValidateEditEventArgs) Handles FGTaxDetails.ValidateEdit
        Try
            Dim i As Integer
            If FGTaxDetails.ColSel = 3 Then
                i = Integer.Parse(FGTaxDetails.Editor.Text)
                If i > 99 Then
                    BCommon.ShowMsgError(10046)
                    e.Cancel = True
                ElseIf i < 0 Then
                    BCommon.ShowMsgError(10239)
                    e.Cancel = True
                End If
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "FGTaxDetails_ValidateEdit")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtMaxQty_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMaxQty.LostFocus
        Try
            If Val(txtMinQty.Text) > Val(txtMaxQty.Text) Then
                BCommon.ShowMsgError(10037)
                txtMinQty.Focus()
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtMaxQty_LostFocus")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub chkSameCompany_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkSameCompany.CheckedChanged
        If btLoading = True Then Exit Sub
        Try
            If chkSameCompany.Checked = True And Not IsNothing(cmbcompanyname.SelectedValue) Then
                cmbmfctrname.SelectedValue = cmbcompanyname.SelectedValue
                cmbmfctrname.Enabled = False
            Else
                cmbmfctrname.Enabled = True
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "chkSameCompany_CheckedChanged")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbUOM_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbUOM.KeyUp
        Try
            If e.KeyCode = Keys.Enter Then cmbSchDrug.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbUOM_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbGenericName_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbGenericName.LostFocus
        Try

            If Trim(cmbGenericName.Text) = "" Then Exit Sub
            If cmbGenericName.SelectedValue = Nothing Then
                Dim objMiscCD As New CMiscCd
                If cmbGenericName.FindStringExact(Trim(cmbGenericName.Text)) < 0 Then
                    objMiscCD.Code_Type = "GENERICNAME"
                    objMiscCD.Description = Trim(cmbGenericName.Text)
                    BMiscCode.Save(objMiscCD, "GENERICNAME")
                    BCommon.SetComboValues(cmbGenericName, "GENERICNAME", True)
                    cmbGenericName.SelectedText = objMiscCD.Description
                End If
            End If

        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbGenericName_LostFocus")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbcompanyname_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbcompanyname.LostFocus
        Try
            If chkSameCompany.Checked = True And Not IsNothing(cmbcompanyname.SelectedValue) Then
                cmbmfctrname.SelectedValue = cmbcompanyname.SelectedValue
                cmbmfctrname.Enabled = False
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "cmbcompanyname_LostFocus")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub cmbLocation_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbLocation.KeyDown
        'Rahul_ITS@20071112
        If e.Alt Then Exit Sub
        '>> END
        If e.KeyCode = Keys.Enter Then
            If sender.selectedindex = -1 Then sender.text = "" Else txtMinQty.Focus()
        End If
    End Sub

    Private Sub cmbLocation_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles cmbLocation.Validating
        If sender.selectedindex = -1 Then sender.text = ""
    End Sub

    Private Sub txtMargin_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtMargin.KeyUp
        'Rahul_ITS@20071119
        Try
            If (BCommon.IsInteger(txtMargin.Text) = False) Then txtMargin.Focus() : txtMargin.Text = ""
            If e.KeyCode = Keys.Enter Then txtMargin.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtMargin_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtELStock_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtELStock.KeyDown
        Try
            'Rahul_ITS@20071119
            If e.Alt Then Exit Sub
            If e.KeyCode = Keys.Shift Then e.SuppressKeyPress = True
            If e.KeyCode = Keys.Enter Then cmbPreferredV1.Focus()
            If e.KeyCode = Keys.Shift Then e.SuppressKeyPress = True
            e.SuppressKeyPress = Not BCommon.ValidateText(e.KeyCode, "NUM", False)

        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtELStock_KeyDown")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub txtELStock_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtELStock.KeyUp
        Try
            'Rahul_ITS@20071119
            If (BCommon.IsInteger(txtELStock.Text) = False) Then txtELStock.Focus() : txtELStock.Text = ""
            If e.KeyCode = Keys.Enter Then txtELStock.Focus()
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "txtELStock_KeyUp")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub fgItemList_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles fgItemList.KeyDown
        If e.KeyCode = Keys.Delete Or e.KeyCode = Keys.Back Then
            fgItemList.Rows.Remove(fgItemList.Row)
        End If
    End Sub

    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            If (DItem.IsItemUsed(intItemNo)) = 0 Then
                If (DItem.DeleteItem(intItemNo)) > 0 Then
                    BCommon.ShowMsgError(10351)
                    txtItemName.Focus()
                    Display_Data()
                    btnSave.Text = "&Save"
                    cmbPurPack.Enabled = True
                    txtPurQty.Enabled = True
                    cmbUOM.Enabled = True
                    cmbSellLoose.Enabled = True
                    btnDelete.Enabled = False
                End If
            Else
                BCommon.ShowMsgError(10350)
                btnDelete.Focus()
            End If
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnDelete_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnNewLocation_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNewLocation.Click
        Dim dtbLocation As DataTable
        Try
            Me.Cursor = Cursors.WaitCursor
            Dim objNewLocation As New frmLocation
            objNewLocation.flgLocation = 1
            objNewLocation.ShowDialog()
            dtbLocation = BCommon.GetLocation()
            BCommon.SetComboValues(cmbLocation, dtbLocation, "LocationID", "LocationCode")
            cmbLocation.SelectedValue = objNewLocation._intLocID
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnNewLocation_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnNewManufctr_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNewManufctr.Click
        Dim dtbCompany As DataTable
        Dim dtbMfctr As DataTable
        Try
            Me.Cursor = Cursors.WaitCursor
            Dim objNewManufacturer As New frmManufacturer
            objNewManufacturer.flgMfctr = 1
            objNewManufacturer.ShowDialog()
            dtbMfctr = BManufacturer.GetManufacturer()
            cmbmfctrname.DataSource = dtbMfctr
            cmbmfctrname.ValueMember = "mfctrID"
            cmbmfctrname.DisplayMember = "mfctrname"
            cmbmfctrname.Splits(0).DisplayColumns(1).Width = cmbmfctrname.Width * 35 / 100
            cmbmfctrname.Splits(0).DisplayColumns(2).Width = cmbmfctrname.Width * 59 / 100
            cmbmfctrname.Columns(1).Caption = "CODE"
            cmbmfctrname.Columns(2).Caption = "COMPANY NAME"
            cmbmfctrname.Splits(0).DisplayColumns(0).Visible = False

            dtbCompany = BManufacturer.GetManufacturer()
            cmbcompanyname.DataSource = dtbCompany
            cmbcompanyname.ValueMember = "mfctrID"
            cmbcompanyname.DisplayMember = "mfctrname"
            cmbcompanyname.Splits(0).DisplayColumns(1).Width = cmbcompanyname.Width * 30 / 100
            cmbcompanyname.Splits(0).DisplayColumns(2).Width = cmbcompanyname.Width * 59 / 100
            cmbcompanyname.Columns(1).Caption = "CODE"
            cmbcompanyname.Columns(2).Caption = "COMPANY NAME"
            cmbcompanyname.Splits(0).DisplayColumns(0).Visible = False

            cmbmfctrname.SelectedValue = objNewManufacturer._intMfctrID
            cmbcompanyname.SelectedValue = objNewManufacturer._intMfctrID
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnNewManufctr_Click")
            Me.Cursor = Cursors.Default
        End Try
    End Sub
    'Private Function checkSubstitute() As Boolean
    '    Try
    '        If btnSave.Text = "&Save" Then
    '            If SetSubstitute().Length - 1 > 0 Then : Return True
    '            Else : Return False
    '            End If
    '        End If
    '        Dim intRes = Array.Equals(SubstituteItem, SetSubstitute())

    '        If intRes = 0 Then : Return False
    '        Else : Return True
    '        End If
    '    Catch ex As Exception
    '        BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "checkSustitute()")
    '    End Try

    'End Function

    'Private Function checkTax() As Boolean
    '    Try
    '        Dim blnchktax As Boolean = False
    '        If btnSave.Text = "&Save" Then
    '            If SetTax().Length - 1 > 0 Then : Return True
    '            Else : Return False
    '            End If
    '        Else
    '            Dim dtsTax As DataSet = DItem.GetTax(intItemNo)

    '            Dim intcount As Integer = 0
    '            For intcount = 0 To dtsTax.Tables(0).Rows.Count - 1
    '                If FGTaxDetails.Item(intcount + 1, 3) <> dtsTax.Tables(0).Rows(intcount).Item(2) Or _
    '                FGTaxDetails.Item(intcount + 1, 0) <> dtsTax.Tables(0).Rows(intcount).Item(3) Then
    '                    blnchktax = True
    '                    Exit For
    '                End If
    '            Next
    '        End If
    '        If blnchktax = True Then : Return True
    '        Else : Return False
    '        End If
    '    Catch ex As Exception
    '        BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "checkTax")
    '    End Try
    'End Function

    Private Sub ccmDItemList_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles ccmDItemList.Enter
        Try
            If IsNothing(ccmDItemList.DataSource) Then
                'Dim dta As DateTime = Now()
                Cursor = Cursors.WaitCursor
                dtbSuDItem = DItem.GetItems()
                ccmDItemList.DataSource = dtbSuDItem
                ccmDItemList.Splits(0).DisplayColumns(1).Width = ccmDItemList.Width * 130 / 100
                ccmDItemList.Splits(0).DisplayColumns(2).Width = ccmDItemList.Width * 65 / 100
                ccmDItemList.Columns(1).Caption = "Item Name"
                ccmDItemList.Columns(2).Caption = "Code"
                ccmDItemList.Splits(0).DisplayColumns(0).Visible = False
                ccmDItemList.DisplayMember = "ItemName"
                'MessageBox.Show((Now() - dta).ToString())
                Cursor = Cursors.Default
            End If
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "ccmDItemList_Enter")
        End Try
    End Sub

    Private Sub lblForm_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblForm.DoubleClick
        Dim objMiscCd As New frmItemMiscCd
        objMiscCd.ShowDialog()
        If objMiscCd.blnItemMaster = 1 Then
            BCommon.SetComboValues(cmbForm, "ITEMFORM")
        End If
    End Sub
End Class